<template>
  <div>
    <div :style="isCommit">
      <el-input
        type="textarea"
        placeholder="请输入内容"
        v-model="textarea"
        maxlength="30"
        show-word-limit
      >
      </el-input>
      <div class="SubMit">
        <el-button type="primary" @click="submit">提交</el-button>
        <el-button type="primary" @click="back ">返回</el-button>
      </div>
    </div>
    <div class="succeed" :style="isShow">
        <el-result icon="success" title="反馈成功" subTitle="请点击按钮进行返回">
          <template slot="extra">
            <el-button type="primary" size="medium" @click="goBack">返回</el-button>
          </template>
        </el-result>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        text: '',
        textarea: '',
        isShow: {
          display: 'none'
        },
        isCommit: {
          display: 'block'
        }
      }
    },
    methods: {
      // 提交到后台数据库
      submit() {
        if (this.textarea.trim() !== '') {
          this.isCommit.display = 'none'
          this.isShow.display = 'block'
          return this.$message.success('反馈成功：' + this.textarea)
        }
        this.$message.error('不能为空')
      },
      back() {},
      goBack() {
        history.back()
      }
    }
  }
</script>

<style scoped>
  .SubMit {
    text-align: center;
    margin-top: 10px;
  }
  .succeed {
    text-align: center;
  }
</style>
